package net.zoneland.knowledge.service.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import net.zoneland.knowledge.model.LoginUserPojo;
import net.zoneland.knowledge.service.AuthService;
import net.zoneland.knowledge.service.UserService;

/**
 * 容器认证实现任务.
 *
 * @author: bcc
 *     2022/3/11
 */
@ConditionalOnProperty(name = "biz.auth-method", havingValue = "userIdParam")
@Service
public class AuthServiceImplUserIdParam implements AuthService {

    @Autowired
    private UserService userService;
    
    @Override
    public LoginUserPojo getLoginUser(final HttpServletRequest request) throws Exception {
        String userId = request.getParameter("userId");
        return userService.getUserByUid(userId);
    }

    @Override
    public boolean isMock() {

        return false;
    }

    @Override
    public String getUserId(final HttpServletRequest request) {

        return request.getParameter("userId");
    }

}
